import Vue from 'vue'
import Vuex from 'vuex'
import {saveStore} from '@/utils/util'
Vue.use(Vuex)
 
// 用来存储数据
const state = {
    username:'',
    password:'',
    uid:null,
    role:"",
    image:""
}
// 操作数据
const mutations = {
  SET_ROLE(state,value){
    state.role=value
    saveStore()
  },
  SET_IMAGE(state,value){
    state.image=value
    saveStore()
  },
  SET_UID(state,value){
    state.uid=value
    saveStore()
  },
  SET_USERNAME(state,value){
     state.username=value
     saveStore()
   },
   SET_PASSWORD(state,value){
    state.password=value
    saveStore()
  },
}
// 新建并暴露store
export default {
    namespaced:true,
    state,
    mutations,
}
 